#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
using namespace std;

typedef pair<long long, long long> PII;

const int N = 200050;

PII arr[N];
int n, k;

struct compare
{
    bool operator()(const PII& p1, const PII& p2)
    {
        if (p1.second != p2.second)
            return p1.second > p2.second;
        else
            return p1.first < p2.first;
    }
};

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)    cin >> arr[i].first;
    for (int i = 0; i < n; i++)    cin >> arr[i].second;

    sort(arr, arr + n, compare());

    long long s1 = 0, s2 = 0;
    for (int i = 0; i < k;i++)
    {
        s1 += arr[i].first;
        s2 += arr[i].second;
    }
    cout << s1 << " " << s2 << endl;
    return 0;
}